<?php
/**
 * Error controller
 *
 * @uses       Zend_Controller_Action
 * @package    QuickStart
 * @subpackage Controller
 * @author haifeng.wu
 */

require_once 'CommonController.php';

class ErrorController extends CommonController
{
    /**
     * error
     *
     * @return void
     */
    public function errorAction()
    {
        $errors = $this->_getParam('error_handler');
        
        switch ($errors->type) { 
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
                // 404 error -- controller or action not found
                $this->getResponse()->setHttpResponseCode(404);
                $this->view->message = '很抱歉，此页面没有找到，请点击<a href="javascript:location.href = location.href;" style="text-decoration:underline">刷新</a>重试。';
                break;

            default:
                // application error 
                $this->getResponse()->setHttpResponseCode(500);
                $this->view->message = '程序错误，你可以点击<a href="javascript:location.href = location.href;" style="text-decoration:underline">刷新</a>重试。如果问题一直没有解决请和管理员联系。';
                //$this->view->message = 'Application error';
                break;
        }

        if ($this->_getParam('test')) {
            $this->view->message = $errors->exception;
        }
        $this->view->exception = $errors->exception;

        $this->view->exception = $errors->exception;
        $this->view->request   = $errors->request;
    }
}